const initState = {
	token: localStorage.getItem('token') || '',
	avator: localStorage.getItem('avator') || '',
	nickname: localStorage.getItem('nickname') || '',
	role: localStorage.getItem('role') || ''
}

export const userReducer = (state = initState, action: any) => {
	switch (action.type) {
		case 'modify_user': {
			return {
				token: action.payload.token,
				avator: action.payload.avator,
				nickname: action.payload.nickname,
				role: action.payload.role
			}
		}
	}
	return state
}